import request from "@/utils/request";
import {UserLoginResultType, UserLoginType, UserPermsInfoType} from "@/api/sys/admin/user/types";
import {RouteRecordRaw} from "vue-router";
import {PATH_SYS_ADMIN} from "@/utils/constant";

const baseUrl = PATH_SYS_ADMIN + '/auth/'

/**
 *  用户登录
 */
export function loginApi(data: UserLoginType): Promise<UserLoginResultType> {
    return request.post(baseUrl + 'login', data)
}

/**
 * 获取当前登录用户的信息
 */
export function getUserInfo(): Promise<UserPermsInfoType> {
    return request.get(baseUrl + 'me')
}

/**
 * 用户登录的时候,获取所有的路由,以树状菜单的形式
 */
export function listRoutesApi(): Promise<RouteRecordRaw[]> {
    return request.get(baseUrl + 'routes')
}